<template>
  <div class="top"><input type="checkbox" v-model="isAllChecked" />全选</div>
</template>
  <!-- 
  利用v-model获取页面内input里checked的值,

   -->
<script>
  import {mapGetters,mapState,mapMutations,mapActions} from "vuex";
export default {
  name: "CartHeader",

  computed: {
    //怎么判断？ 已选的数量==数组的长度 全选✅
    //已选的数量，数组的长度
    //list的长度

    ...mapGetters(["totall","selectNum"]),
   
    //是否全选
    isAllChecked: {
      get() {
        //一定是return 一个布尔值
        return this.totall === this.selectNum;
      },
      set(value) {
        this.$emit("changeAll", value);
      },
    },
  },
};
</script>

<style>
.top {
  height: 40px;
  display: flex;
  align-items: center;
  background-color: pink;
}

.top > input {
  width: 20px;
  height: 20px;
  margin: 0 20px;
}
</style>
